package cn.unknowpupil.init.service.impl;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import cn.unknowpupil.init.service.ILeaseLogService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import cn.unknowpupil.init.mapper.LeaseLogMapper;
import cn.unknowpupil.init.domain.LeaseLog;

/**
 * 交租日志Service业务层处理
 *
 * @author uunknowpupil
 * @date Tue Dec 01 09:45:21 CST 2020
 */

/**
 * Created at Tue Dec 01 09:45:21 CST 2020 by  w10g <br>
 * Initialize 交租日志Service  ... <br>
 * 交租日志Service业务层处理
 *
 * @author uunknowpupil
 * @since 0.0.1
 */
@Service
public class LeaseLogServiceImpl extends ServiceImpl<LeaseLogMapper,LeaseLog> implements ILeaseLogService {


    /**
     * 查询交租日志
     *
     * @param id 交租日志ID
     * @return 交租日志
     */
    @Override
    public LeaseLog selectLeaseLogById(Long id) {
        return super.getById(id);
    }

    /**
     * 查询交租日志列表
     *
     * @param leaseLog 交租日志
     * @return 交租日志
     */
    @Override
    public List<LeaseLog> selectLeaseLogList(LeaseLog leaseLog) {
        return baseMapper.selectLeaseLogList(leaseLog);
    }

    /**
     * 分页查询交租日志列表
     *
     * @param current {@code int} 页码
     * @param size    {@code int} 笔数
     * @param leaseLog {@link LeaseLog} 交租日志
     * @return {@code IPage<SysRole>}
     */
    @Override
    public IPage<LeaseLog> selectLeaseLogPages(int current, int size, LeaseLog leaseLog) {
        IPage<LeaseLog> page = new Page<>(current, size);
        return baseMapper.selectLeaseLogPages(page, leaseLog);
    }


    /**
     * 新增交租日志
     *
     * @param leaseLog 交租日志
     * @return 结果
     */
    @Override
    public boolean insertLeaseLog(LeaseLog leaseLog) {
        return super.save(leaseLog);
    }

    /**
     * 修改交租日志
     *
     * @param leaseLog 交租日志
     * @return 结果
     */
    @Override
    public boolean updateLeaseLog(LeaseLog leaseLog) {
        return super.updateById(leaseLog);
    }

    /**
     * 批量删除交租日志
     *
     * @param ids 需要删除的交租日志ID
     * @return 结果
     */
    @Override
    public boolean deleteLeaseLogByIds(Long[] ids) {
        List<Long> collect = Stream.of(ids).collect(Collectors.toList());
        return super.removeByIds(collect);
    }

    /**
     * 删除交租日志信息
     *
     * @param id 交租日志ID
     * @return 结果
     */
    @Override
    public boolean deleteLeaseLogById(Long id) {
        return super.removeById(id);
    }
}
